#!/sbin/openrc-run
supervisor=supervise-daemon

name="Container Daemon"
description="Standalone containerd (usually started by Docker)"

extra_started_commands="reload"
description_reload="Reload configuration without exiting"

command="/usr/bin/containerd"
command_args="${containerd_opts}"
rc_ulimit="${ulimit_opts:--c unlimited -n 1048576 -u unlimited}"
retry="${signal_retry:-TERM/60/KILL/10}"

log_file="${log_file:-/var/log/${RC_SVCNAME}.log}"
err_file="${err_file:-${log_file}}"
log_mode="${log_mode:-0644}"
log_owner="${log_owner:-root:root}"

supervise_daemon_args="--stderr \"${err_file}\" --stdout \"${log_file}\""

depend() {
	need sysfs cgroups
}

start_pre() {
	checkpath -f -m "$log_mode" -o "$log_owner" "$log_file" "$err_file"
}

reload() {
	ebegin "Reloading configuration"
	$supervisor $RC_SVCNAME --signal HUP
	eend $?
}
